
def mykey(k):
    t=0
    for a in k:
        n=str(ord(a))[-1]
        n1=str(ord(a))[-2:-1] 
        t=t+int(n)+int(n1)
    return t

def myencrypt(mystr,key):
    key=mykey(key)
    str_asc=[]
    for a in mystr:
        str_asc.append(ord(a))
    move_str=[]    
    for j in str_asc:    
        b=j+key
        move_str.append(chr(b))
    return move_str

def mydecrypt(my_str,key):
    key=mykey(key)
    str_asc=[]
    for a in my_str:
        str_asc.append(ord(a))
    move_str=[]    
    for j in str_asc:    
        b=j-key
        move_str.append(chr(b))
    return move_str

if __name__=='__main__':
    my_str=input("输入字符：")
    my_k=input("输入key：")
    res_str="".join(myencrypt(my_str,my_k))
    print(res_str)
    res_str="".join(mydecrypt(res_str,my_k))
    print(res_str)
